using UFSoft.UBF.Business;

namespace ufida.u9.cust.dz.beplugin
{
    public class BaseCommon
    {
        public static bool TryGetEntity<T>(object[] args, ref T entity) where T : BusinessEntity
        {
            if (args == null || args.Length == 0 || !(args[0] is EntityEvent))
                return false;
            BusinessEntity.EntityKey key = ((EntityEvent)args[0]).EntityKey;
            if (key == null)
                return false;

            entity = key.GetEntity() as T;

            if (entity == null)
                return false;

            return true;
        }
    }
}
